package holdem;

/**
 *
 * @author Pai Qi
 * @author qipai0@gmail.com
 * Description:
 * Start Date:
 *
 */

import java.util.*;

public class Deck {
    private List<Card> allCards = new ArrayList<Card>();
    private Random     rand     = new Random();

    //~--- constructors -------------------------------------------------------

    public Deck() {
        int addedCard = 0;
	for (int value = 1; value <= 13; value++) {
	    for (Card.Suite suite : Card.Suite.values()) {
		allCards.add(rand.nextInt(++addedCard), new Card(suite, value));
	    }
	}
    }

    //~--- methods ------------------------------------------------------------

    public Card take() {
	if (allCards.isEmpty()) {
	    return null;
	}

        return allCards.remove(allCards.size()-1);
    }

    public void fire() {
        take();
    }

    public boolean isEmpty() {
	return allCards.isEmpty();
    }

}
